<?php

namespace App\Repository;
use Hyperf\DbConnection\Db;

/**
 * 联系人数据仓储数据类
 *
 * @author WangBin
 */
class ContactsRepo extends BaseRepo
{
    /**
     * 根据用户 id 查询联系人
     *
     * @param int $userId
     * @return \Hyperf\Database\Model\Builder|\Hyperf\Database\Model\Model|object|null
     */
    public function getByUserId(int $userId)
    {
        return Db::table("im_contacts")
            ->select(['im_contacts.*', 'im_users.username'])
            ->leftJoin('im_users', 'im_contacts.friend_id', '=', 'im_users.id')
            ->where('im_users.id', $userId);
    }

    public function searchNewFriends(array $filter = [])
    {
        return Db::table('im_users')
            ->select(['im_users.avatar', 'im_users.username', 'id'])
            ->
    }
}